home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 2001 January / CT_SW0101.ISO / pc / software / kommunik / multimed / snakcarb.sit / Snak 4.6.3 Carbon / Scripts / pp-bots.irc < prev    next >
Text File  |  2000-08-23  |  25KB  |  786 lines

  1. # ########################################################################## #
  2. #                      PurePak - The sequel to TextBox                       #
  3. #                          A -+ TEXT +- production                           #
  4. # ########################################################################## #
  5. # Author: Crypt Keeper [ckeeper@axiom.access.one.net] (CKeeper on IRC)
  6. # Version 2.07
  7. #
  8. # This script requires at least ircII2.2.9 (Unix) or a fully ircII compatible
  9. # client.  It has only been tested under Unix with ircII2.2.9 and ircII2.8.
  10. #
  11. # This file may not be edited in a DOS text editor _OR_ converted with
  12. # utilities such as unix2dos/dos2unix.  It contains characters that will
  13. # be lost or corrupted in either case.
  14. #
  15. # PurePak version 2.07 IRC script
  16. # Copyright (C) 1995
  17. #
  18. # This program is free software; you can redistribute it and/or modify
  19. # it under the terms of the GNU General Public License as published by
  20. # the Free Software Foundation; either version 1, or (at your option)
  21. # any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful,
  24. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  26. # GNU General Public License for more details.
  27. #
  28. # You should have received a copy of the GNU General Public License
  29. # along with this program; if not, write to the Free Software
  30. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  31. # ########################################################################## #
  32.  
  33. # DCC RAW bots script - no floods or war commands in here, only basic bot
  34. # control and guarding/spy functions
  35.  
  36. EVAL ^if (!(PPVERS)) {/echo *** pp-bots.irc cannot be loaded as a stand-alone script.  It must be loaded after purepak.irc.;//exit}
  37. @ PP.BOTS = 1
  38.  
  39. # ----------------------------------------------------------------------------
  40. # Variables to add to /pp
  41. # ----------------------------------------------------------------------------
  42.  
  43. # Default bot options that bots are created with
  44. EVAL ^if (!(PP.SET.BOTS_DFL_OPT)) {@ PP.SET.BOTS_DFL_OPT = [X]}
  45.  
  46. # Alias to set bots script options
  47. @ PP.SETCHECKS.BOTS = [/pp.set.bots]
  48.  
  49. # DEFBotopt = Default bot options
  50. alias pp.set.bots {
  51.     if (match(DEFB* $0))
  52.     {
  53.         if ([$1]) {@ PP.SET.BOTS_DFL_OPT = bots.setbotopt($PP.SET.BOTS_DFL_OPT $1-)}
  54.         echo *** Default bot options are now: $bots.querybotopt($PP.SET.BOTS_DFL_OPT)
  55.         @ VU = 1
  56.     }
  57. }
  58.  
  59. # ----------------------------------------------------------------------------
  60. # Aliases for controlling bot options
  61. # ----------------------------------------------------------------------------
  62.  
  63. alias bots.querybotopt {
  64.     if (index(F $0) >= 0) {@ BOTMODS = [FOLLOW ]}
  65.     if (index(L $0) >= 0) {@ BOTMODS = BOTMODS##[FOLLOWLEAVE ]}
  66.     if (index(M $0) >= 0) {@ BOTMODS = BOTMODS##[SPYMSG ]}
  67.     if (index(P $0) >= 0) {@ BOTMODS = BOTMODS##[SPYPUB ]}
  68.     if (index(C $0) >= 0) {@ BOTMODS = BOTMODS##[SPYCTCP ]}
  69.     if (index(J $0) >= 0) {@ BOTMODS = BOTMODS##[SPYJUNK ]}
  70.     if (index(O $0) >= 0) {@ BOTMODS = BOTMODS##[OPSGUARD ]}
  71.     if (index(K $0) >= 0) {@ BOTMODS = BOTMODS##[KICKGUARD ]}
  72.     if (index(B $0) >= 0) {@ BOTMODS = BOTMODS##[BANGUARD]}
  73.     @ FUNCTION_RETURN = BOTMODS
  74.     ^assign -BOTMODS
  75. }
  76.  
  77. # bots.setbotopt <current opt string> <settings/-settings>
  78. # Possible settings:
  79. # FOLLOW,FOLLOWLEAVE,SPYMSG,SPYPUB,SPYCTCP,SPYJUNK,OPSGUARD,KICKGUARD,BANGUARD
  80. alias bots.setbotopt {
  81.     @ NEWOPT = [$0]
  82.     if (match(-FOLLOW $1-)) {@ NEWOPT = strip(F $NEWOPT)}
  83.     if (match(FOLLOW $1-)) {^if (index(F $NEWOPT) < 0) {@ NEWOPT = NEWOPT##[F]}}
  84.     if (match(-FOLLOWL* $1-)) {@ NEWOPT = strip(L $NEWOPT)}
  85.     if (match(FOLLOWL* $1-)) {^if (index(L $NEWOPT) < 0) {@ NEWOPT = NEWOPT##[L]}}
  86.     if (match(-SPYM* $1-)) {@ NEWOPT = strip(M $NEWOPT)}
  87.     if (match(SPYM* $1-)) {^if (index(M $NEWOPT) < 0) {@ NEWOPT = NEWOPT##[M]}}
  88.     if (match(-SPYP* $1-)) {@ NEWOPT = strip(P $NEWOPT)}
  89.     if (match(SPYP* $1-)) {^if (index(P $NEWOPT) < 0) {@ NEWOPT = NEWOPT##[P]}}
  90.     if (match(-SPYC* $1-)) {@ NEWOPT = strip(C $NEWOPT)}
  91.     if (match(SPYC* $1-)) {^if (index(C $NEWOPT) < 0) {@ NEWOPT = NEWOPT##[C]}}
  92.     if (match(-SPYJ* $1-)) {@ NEWOPT = strip(J $NEWOPT)}
  93.     if (match(SPYJ* $1-)) {^if (index(J $NEWOPT) < 0) {@ NEWOPT = NEWOPT##[J]}}
  94.     if (match(-OPS* $1-)) {@ NEWOPT = strip(O $NEWOPT)}
  95.     if (match(OPS* $1-)) {^if (index(O $NEWOPT) < 0) {@ NEWOPT = NEWOPT##[O]}}
  96.     if (match(-KICK* $1-)) {@ NEWOPT = strip(K $NEWOPT)}
  97.     if (match(KICK* $1-)) {^if (index(K $NEWOPT) < 0) {@ NEWOPT = NEWOPT##[K]}}
  98.     if (match(-BAN* $1-)) {@ NEWOPT = strip(B $NEWOPT)}
  99.     if (match(BAN* $1-)) {^if (index(B $NEWOPT) < 0) {@ NEWOPT = NEWOPT##[B]}}
  100.     @ FUNCTION_RETURN = NEWOPT
  101.     ^assign -NEWOPT
  102. }
  103.  
  104. # ----------------------------------------------------------------------------
  105. # ONs and guardbot code
  106. # ----------------------------------------------------------------------------
  107.  
  108. on #^join 21 * {
  109.     if ([$0] == N) {
  110.         ^foreach BOTS AA {
  111.             if (index(F $word(5 $BOTS[$AA])) >= 0) {//^dcc raw $word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) JOIN $1}
  112.             if (index(O $word(5 $BOTS[$AA])) >= 0) {//^dcc raw $word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) MODE $1 +o $N}
  113.         }
  114.     }
  115.     if ((match($0 $PP.OPGUARDS))&&(gotops($1))) {//mode $1 +o $0}
  116. }
  117. on #^leave 21 * {^if ([$0] == N) {^foreach BOTS AA {^if (index(L $word(5 $BOTS[$AA])) >= 0) {//^dcc raw $word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) PART $1}}}}
  118.  
  119. on #^mode 21 * {
  120.     if ([$0] != N)
  121.     {
  122.         if (match(*+b* $2))
  123.         {
  124.             @ CSTR = N##[!$PP.UHOST]
  125.             if (rmatch($CSTR $3-))
  126.             {
  127.                 if (match($3 $CSTR)) {@ UNBANZ = [$3 ]}
  128.                 if (match($4 $CSTR)) {@ UNBANZ = UNBANZ##[$4 ]}
  129.                 if (match($5 $CSTR)) {@ UNBANZ = UNBANZ##[$5 ]}
  130.                 if (match($6 $CSTR)) {@ UNBANZ = UNBANZ##[$6 ]}
  131.                 foreach BOTS AA {
  132.                     if (index(B $word(5 $BOTS[$AA])) >= 0)
  133.                     {
  134.                         //dcc raw $word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) MODE $1 -o-bbbb $0 $UNBANZ
  135.                         @ BOTSTRIGD = 1
  136.                     }
  137.                 }
  138.                 if (BOTSTRIGD) {/echo *** Guardbot BAN protection triggered by $0 on channel $1}
  139.                 ^assign -UNBANZ
  140.                 ^assign -BOTSTRIGD
  141.             }
  142.             ^assign -CSTR
  143.         }
  144.         if (!gotops($1)) {^if ((match(*+o* $2))&&(match($N $3-))) {^timer 1 ^bots.opchk $0 $1}}
  145.         {
  146.             if (match(*-o* $2))
  147.             {
  148.                 if (match($N $3-)) {^timer 1 ^bots.dopchk $0 $1}
  149.                 if (match($3 $PP.OPGUARDS)) {//mode $1 +o $3}
  150.                 if (match($4 $PP.OPGUARDS)) {//mode $1 +o $4}
  151.                 if (match($5 $PP.OPGUARDS)) {//mode $1 +o $5}
  152.                 if (match($6 $PP.OPGUARDS)) {//mode $1 +o $6}
  153.             }
  154.         }
  155.     }
  156. }
  157. alias bots.opchk {
  158.     if (gotops($1))
  159.     {
  160.         ^on ^who * {^if ((match($1 $PP.OPGUARDS))&&(!match(*@* $2))) {//mode $0 +o $1}}
  161.         //^who $1
  162.         wait -CMD if (1) {
  163.             ^on who -
  164.             ^assign -OBZ
  165.         }
  166.     }
  167. }
  168. alias bots.dopchk {
  169.     if (!gotops($1))
  170.     {
  171.         foreach BOTS AA {
  172.             if (index(O $word(5 $BOTS[$AA])) >= 0)
  173.             {
  174.                 //dcc raw $word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) MODE $1 -o+o $0 $N
  175.                 @ BOTSTRIGD = 1
  176.             }
  177.         }
  178.         if (BOTSTRIGD) {/echo *** Guardbot DEOP protection triggered by $0 on channel $1}
  179.         ^assign -BOTSTRIGD
  180.     }
  181. }
  182.  
  183. alias bots.onkick {
  184.     if ([$3] == N)
  185.     {
  186.         foreach BOTS AA {^if (index(K $word(5 $BOTS[$AA])) >= 0) {//dcc raw $word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) KICK $2 $KNICK :That wasn't very smart!}}
  187.     }
  188. }
  189.  
  190. alias bots.makevars {
  191.     ^assign -PP.OPGUARDS
  192.     ^assign -PP.BOTNICKS
  193.     foreach BOTS AA {
  194.         if (index(O $word(5 $BOTS[$AA])) >= 0) {@ PP.OPGUARDS = PP.OPGUARDS##[$word(3 $BOTS[$AA]) ]}
  195.         @ PP.BOTNICKS = PP.BOTNICKS##[$word(3 $BOTS[$AA]) ]
  196.     }
  197. }
  198.  
  199. # Ops all of your bots on channel
  200. alias opbots {
  201.     ^on ^who * {^if (match($1 $PP.BOTNICKS)) {@ BTZ = BTZ##[$1 ]}}
  202.     //^who *
  203.     wait -CMD if (1) {
  204.         ^on who -
  205.         if (BTZ)
  206.         {
  207.             op $BTZ
  208.             ^assign -BTZ
  209.         } {/echo *** You don't have any bots on $C}
  210.     }
  211. }
  212.  
  213. # /bot massdeop
  214. # massdeops current channel 4 at a time using all bots on channel as helpers
  215. alias bots.massdeop {
  216.     echo *** Massdeopping $C using all clonebots on channel
  217.     ^on ^who * {
  218.         ^if (match($1 $PP.BOTNICKS))
  219.         {
  220.             if (!match(*@* $2)) {@ BTZ = BTZ##[$1 ]}
  221.             @ GBOTZ = 1
  222.         }
  223.     }
  224.     echo *** Making sure all bots have ops...
  225.     //^who *
  226.     wait -CMD if (1) {
  227.         ^on who -
  228.         if (GBOTZ)
  229.         {
  230.             op $BTZ
  231.             @ CT = 0
  232.             while (word($CT $BTZ))
  233.             {
  234.                 @ BN = 0
  235.                 foreach BOTS AA {^if (word(3 $BOTS[$AA]) == word($CT $BTZ)) {@ BN = AA}}
  236.                 if (BN) {@ BTZ2 = BTZ2##[$BN ]}
  237.                 @ CT = CT + 1
  238.             }
  239.             ^timer 2 /echo *** Massdeopping in about 8 seconds...
  240.             ^assign -BN
  241.             ^assign -BTZ
  242.             ^assign -CT
  243.             EVAL ^timer 10 ^bots.massdeop.doit $C $BTZ2
  244.             ^assign -GBOTZ
  245.             ^assign -BTZ2
  246.         } {/echo *** You have no bots on $C}
  247.     }
  248. }
  249. alias bots.massdeop.doit {
  250.     @ MDCHAN = [$0]
  251.     @ MDNUMS = [$1-]
  252.     ^on ^who * {^if ((!match($1 $PP.BOTNICKS))&&([$1] != N)) {@ MDOPZ = MDOPZ##[$1 ]}}
  253.     echo *** Massdeopping using bots: $MDNUMS
  254.     //^who -chops *
  255.     wait -CMD if (1) {
  256.         ^on who -
  257.         @ MDNUMS = [65535 ]##MDNUMS
  258.         @ BOTCTR = 0
  259.         @ NICKCTR = 0
  260.         while (word($NICKCTR $MDOPZ))
  261.         {
  262.             @ LISTS[$BOTCTR] = LISTS[$BOTCTR]##[$word($NICKCTR $MDOPZ) ]
  263.             @ NICKCTR = NICKCTR + 1
  264.             @ BOTCTR = BOTCTR + 1
  265.             if (BOTCTR >= [$#MDNUMS]) {@ BOTCTR = 0}
  266.         }
  267.         foreach LISTS AA {
  268.             bots.massdeop.dodeops $MDCHAN $word($AA $MDNUMS) $LISTS[$AA]
  269.             ^assign -LISTS[$AA]
  270.         }
  271.         @ BOTCTR = 0
  272.         while (word($BOTCTR $MDNUMS))
  273.         {
  274.             bots.massdeop.dodeops $MDCHAN $word($BOTCTR $MDNUMS) $MDOPZ
  275.             @ BOTCTR = BOTCTR + 1
  276.         }
  277.         EVAL ^timer 2 ^bot * mode $MDCHAN +o $N
  278.         ^assign -MDOPZ
  279.         ^assign -MDNUMS
  280.         ^assign -BOTCTR
  281.         ^assign -NICKCTR
  282.         ^assign -MDCHAN
  283.     }
  284. }
  285. alias bots.massdeop.dodeops {
  286.     if ([$1] == 65535)
  287.     {
  288.         //mode $0 -oooo $2 $3 $4 $5
  289.         if ([$6]) {^bots.massdeop.dodeops $0 $1 $6-}
  290.     }
  291.     {
  292.         //dcc raw $word(0 $BOTS[$1]) $word(1 $BOTS[$1]) MODE $0 -oooo $2 $3 $4 $5
  293.         if ([$6]) {^bots.massdeop.dodeops $0 $1 $6-}
  294.     }
  295. }
  296.  
  297. # ----------------------------------------------------------------------------
  298. # Handlers for clonebot spy functions
  299. # ----------------------------------------------------------------------------
  300.  
  301. alias bots.dospyons {
  302.     foreach BOTS AA {
  303.         if (rmatch($word(5 $BOTS[$AA]) *M* *P* *C*))
  304.         {
  305.             EVAL ^on ^dcc_raw "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % PRIVMSG *" {^bots.gotmsg $BOTSOCKS[$0] $strip(
  306.  $3-)}
  307.             EVAL ^on ^dcc_raw "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % NOTICE *" {^bots.gotmsg $BOTSOCKS[$0] $strip(
  308.  $3-)}
  309.         }
  310.         {
  311.             EVAL ^on dcc_raw - "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % PRIVMSG *"
  312.             EVAL ^on dcc_raw - "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % NOTICE *"
  313.         }
  314.         if (index(J $word(5 $BOTS[$AA])) >= 0)
  315.         {
  316.             EVAL ^on ^dcc_raw "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % JOIN *" {^bots.gotjunk $BOTSOCKS[$0] $strip(
  317.  $3-)}
  318.             EVAL ^on ^dcc_raw "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % PART *" {^bots.gotjunk $BOTSOCKS[$0] $strip(
  319.  $3-)}
  320.             EVAL ^on ^dcc_raw "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % QUIT *" {^bots.gotjunk $BOTSOCKS[$0] $strip(
  321.  $3-)}
  322.             EVAL ^on ^dcc_raw "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % MODE *" {^bots.gotjunk $BOTSOCKS[$0] $strip(
  323.  $3-)}
  324.             EVAL ^on ^dcc_raw "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % NICK *" {^bots.gotjunk $BOTSOCKS[$0] $strip(
  325.  $3-)}
  326.             EVAL ^on ^dcc_raw "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % KICK *" {^bots.gotjunk $BOTSOCKS[$0] $strip(
  327.  $3-)}
  328.         }
  329.         {
  330.             EVAL ^on dcc_raw - "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % JOIN *"
  331.             EVAL ^on dcc_raw - "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % PART *"
  332.             EVAL ^on dcc_raw - "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % QUIT *"
  333.             EVAL ^on dcc_raw - "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % MODE *"
  334.             EVAL ^on dcc_raw - "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % NICK *"
  335.             EVAL ^on dcc_raw - "$word(0 $BOTS[$AA]) $word(1 $BOTS[$AA]) D % KICK *"
  336.         }
  337.     }
  338. }
  339.  
  340. # bots.clearspyons <botno>
  341. alias bots.clearons {
  342.     EVAL ^on dcc_raw - "$word(0 $BOTS[$0]) $word(1 $BOTS[$0]) D % PRIVMSG *"
  343.     EVAL ^on dcc_raw - "$word(0 $BOTS[$0]) $word(1 $BOTS[$0]) D % NOTICE *"
  344.     EVAL ^on dcc_raw - "$word(0 $BOTS[$0]) $word(1 $BOTS[$0]) D % JOIN *"
  345.     EVAL ^on dcc_raw - "$word(0 $BOTS[$0]) $word(1 $BOTS[$0]) D % PART *"
  346.     EVAL ^on dcc_raw - "$word(0 $BOTS[$0]) $word(1 $BOTS[$0]) D % QUIT *"
  347.     EVAL ^on dcc_raw - "$word(0 $BOTS[$0]) $word(1 $BOTS[$0]) D % MODE *"
  348.     EVAL ^on dcc_raw - "$word(0 $BOTS[$0]) $word(1 $BOTS[$0]) D % NICK *"
  349.     EVAL ^on dcc_raw - "$word(0 $BOTS[$0]) $word(1 $BOTS[$0]) D % KICK *"
  350.     EVAL ^on dcc_raw - "$word(0 $BOTS[$0]) $word(1 $BOTS[$0]) C*"
  351.     EVAL ^on dcc_raw - "$word(0 $BOTS[$0]) $word(1 $BOTS[$0]) D PING *"
  352. }
  353.  
  354. alias bots.gotmsg {
  355.     if (([$2] == [PRIVMSG])&&(!match(*.* $nickonly($1))))
  356.     {
  357.         if (match(** $4-)) {^bots.gotctcp $*}
  358.         {
  359.             if (ischannel($3)) {^if (index(P $word(5 $BOTS[$0])) >= 0) {/echo [$0:$word(3 $BOTS[$0])] <$nickonly($strip(: $1)):$3> $strip(: $4) $5-}}
  360.             {^if (index(M $word(5 $BOTS[$0])) >= 0) {/echo [$0:$word(3 $BOTS[$0])] [$strip(: $1)] $strip(: $4) $5-}}
  361.         }
  362.     }
  363.     {
  364.         if (!match(*.* $nickonly($1)))
  365.         {
  366.             if (match(** $4-)) {^bots.gotctcp $*}
  367.             {
  368.                 if (ischannel($3)) {^if (index(P $word(5 $BOTS[$0])) >= 0) {/echo [$0:$word(3 $BOTS[$0])] -$nickonly($strip(: $1)):$3\- $strip(: $4) $5-}}
  369.                 {^if (index(M $word(5 $BOTS[$0])) >= 0) {/echo [$0:$word(3 $BOTS[$0])] -$strip(: $1)- $strip(: $4) $5-}}
  370.             }
  371.         }
  372.     }
  373. }
  374. alias bots.gotctcp {^if (index(C $word(5 $BOTS[$AA])) >= 0) {/echo [$0:$word(3 $BOTS[$0])] CTCP from $nickonly($strip(: $1)) to $3: $strip(: $4-)}}
  375. alias bots.gotjunk {
  376.     if ([$2] == [JOIN])
  377.     {
  378.         echo [$0:$word(3 $BOTS[$0])] $nickonly($strip(: $1)) \($strip( $mid(${index(! $1)+1} $rindex($right(1 $1) $1) $1))\) has joined channel $strip(: $3)
  379.     }
  380.     if ([$2] == [PART])
  381.     {
  382.         echo [$0:$word(3 $BOTS[$0])] $nickonly($strip(: $1)) has left channel $strip(: $3)
  383.     }
  384.     if ([$2] == [QUIT])
  385.     {
  386.         echo [$0:$word(3 $BOTS[$0])] Signoff: $nickonly($strip(: $1)) \($strip(: $3-)\)
  387.     }
  388.     if ([$2] == [MODE])
  389.     {
  390.         echo [$0:$word(3 $BOTS[$0])] Mode change "$strip(: $4-)" on channel $strip(: $3) by $nickonly($strip(: $1))
  391.     }
  392.     if ([$2] == [NICK])
  393.     {
  394.         echo [$0:$word(3 $BOTS[$0])] $nickonly($strip(: $1)) is now known as $strip(: $3)
  395.     }
  396.     if ([$2] == [KICK])
  397.     {
  398.         if ([$4] == word(3 $BOTS[$0]))
  399.         {
  400.             echo [$0:$word(3 $BOTS[$0])] I have been kicked off channel $3 by $nickonly($strip(: $1)) \($strip(: $5-)\)
  401.         }
  402.         {
  403.             echo [$0:$word(3 $BOTS[$0])] $4 has been kicked off channel $3 by $nickonly($strip(: $1)) \($strip(: $5-)\)
  404.         }
  405.     }
  406. }
  407.  
  408. # ----------------------------------------------------------------------------
  409. # Internal bot creation/control aliases
  410. # ----------------------------------------------------------------------------
  411.  
  412. # Bot array: BOTS[botno] :
  413. #   word 0 - socket
  414. #   word 1 - server
  415. #   word 2 - port on server
  416. #   word 3 - nick
  417. #   word 4 - username
  418. #   word 5 - options - see below
  419. #   word 6+ - IRCName
  420.  
  421. # Socket quick-id array: BOTSOCKS[socket] = botno
  422.  
  423. # Bot options:
  424. #   F - Follow you as you join channels
  425. #   L - Also follow you as you leave channels
  426. #   M - Report private msgs it gets to you
  427. #   P - Report public chatter to you
  428. #   C - Report CTCPs to you
  429. #   J - Report junk (joins, leaves, signoffs, nick changes, etc.) to you
  430. #   O - Ops guardbot mode - you keep bot opped, bot keeps you opped
  431. #   K - Kick defense guard mode - if bot has ops, retaliate if you are kicked
  432. #   B - Ban defense guard mode - bot takes action if you are banned
  433.  
  434. # bots.domake <botno> <server> <port> <nick> <username> <options> <IRCName>
  435. alias bots.domake {
  436.     ^set display off
  437.     @ NEWSOCK = connect($1 $2)
  438.     ^set display on
  439.     if (NEWSOCK >= 0)
  440.     {
  441.         //dcc raw $NEWSOCK $1 NICK $3
  442.         //dcc raw $NEWSOCK $1 USER $4 . . :$6-
  443.         //dcc raw $NEWSOCK $1 MODE $3 +i
  444.         @ BOTS[$0] = [$NEWSOCK ]##[$1-]
  445.         @ BOTSOCKS[$NEWSOCK] = [$0]
  446.         EVAL ^on ^dcc_raw "$NEWSOCK $1 C*" {/EVAL ^timer 1 ^bots.connclosed $BOTSOCKS[$0]}
  447.         EVAL ^on ^dcc_raw "$NEWSOCK $1 D PING *" {//dcc raw $0 $1 PONG}
  448.         @ FUNCTION_RETURN = 1
  449.     } {@ FUNCTION_RETURN = 0}
  450.     ^assign -NEWSOCK
  451. }
  452.  
  453. alias bots.connclosed {
  454.     echo *** Bot #$0 disconnected by server $word(1 $BOTS[$0])
  455.     ^bots.clearons $0
  456.     ^assign -BOTSOCKS[$word(0 $BOTS[$0])]
  457.     ^assign -BOTS[$0]
  458.     ^bots.makevars
  459. }
  460.  
  461. # bots.dokill <botno> <signoff msg>
  462. alias bots.dokill {
  463.     if (BOTS[$0])
  464.     {
  465.         ^bots.clearons $0
  466.         //dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) QUIT :$1-
  467.         EVAL ^timer 4 //^dcc close raw $word(0 $BOTS[$0])
  468.         ^assign -BOTSOCKS[$word(0 $BOTS[$0])]
  469.         ^assign -BOTS[$0]
  470.         ^bots.makevars
  471.         @ FUNCTION_RETURN = 1
  472.     } {@ FUNCTION_RETURN = 0}
  473. }
  474.  
  475. # bots.setopt <botno> <option index> <new value>
  476. alias bots.setopt {
  477.     @ CTR = 0
  478.     while (word($CTR $BOTS[$0]))
  479.     {
  480.         if ([$1] == CTR) {@ NBOTS = NBOTS##[$2 ]} {@ NBOTS = NBOTS##[$word($CTR $BOTS[$0]) ]}
  481.         @ CTR = CTR + 1
  482.     }
  483.     @ BOTS[$0] = NBOTS
  484.     ^assign -NBOTS
  485.     ^assign -CTR
  486. }
  487.  
  488. # bots.action <botno> <command> [<parameters>]
  489. # Commands:
  490. #    JOIN [<channel>]
  491. #    LEAVE [<channel>]
  492. #    MSG <nick/channel> <msg>
  493. #    SAY [<#channel>] <msg>
  494. #    NOTICE <nick/channel> <msg>
  495. #    NICK <new nick>
  496. #    RANDNICK
  497. #    CTCP <nick/channel> <ctcp-cmd>
  498. #    MODE [<#channel>] <mode>
  499. #    QUOTE <line to send to server>
  500. #    INVITE <nick> [<channel>]
  501. #    SET <options/-options>
  502. #    ME [<channel>] <msg>
  503. alias bots.action {
  504.     if ([$1] == [ME])
  505.     {
  506.         if (ischannel($2)) {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) PRIVMSG $2 :ACTION $3-}
  507.         {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) PRIVMSG $C :ACTION $2-}
  508.         @ BC = 1
  509.     }
  510.     if ([$1] == [KILL])
  511.     {
  512.         bot kill $0 $2-
  513.         @ BC = 1
  514.     }
  515.     if ([$1] == [JOIN])
  516.     {
  517.         if ([$2])
  518.         {
  519.             if (ischannel($2)) {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) JOIN $2} {/dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) JOIN #$2}
  520.         } {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) JOIN $C}
  521.         if ([$3]) {^bots.action $0 JOIN $3-}
  522.         @ BC = 1
  523.     }
  524.     if ([$1] == [LEAVE])
  525.     {
  526.         if ([$2])
  527.         {
  528.             if (ischannel($2)) {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) PART $2} {/dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) PART #$2}
  529.         } {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) PART $C}
  530.         @ BC = 1
  531.     }
  532.     if ([$1] == [MSG])
  533.     {
  534.         if ([$3]) {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) PRIVMSG $2 :$3-} {/echo *** Must specify a target and message}
  535.         @ BC = 1
  536.     }
  537.     if ([$1] == [SAY])
  538.     {
  539.         if ([$2])
  540.         {
  541.             if (ischannel($2))
  542.             {
  543.                 if ([$3]) {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) PRIVMSG $2 :$3-} {/echo *** Must specify a message}
  544.             } {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) PRIVMSG $C :$2-}
  545.         } {/echo *** Must specify a message}
  546.         @ BC = 1
  547.     }
  548.     if ([$1] == [NOTICE])
  549.     {
  550.         if ([$3]) {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) NOTICE $2 :$3-} {/echo *** Must specify a target and message}
  551.         @ BC = 1
  552.     }
  553.     if ([$1] == [NICK])
  554.     {
  555.         if ([$2])
  556.         {
  557.             //dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) NICK $2
  558.             bots.setopt $0 3 $2
  559.         } {/echo *** Must specify a nick}
  560.         @ BC = 1
  561.     }
  562.     if ([$1] == [SET])
  563.     {
  564.         if ([$2])
  565.         {
  566.             bots.setopt $0 5 $bots.setbotopt($word(5 $BOTS[$0]) $2-)
  567.         }
  568.         echo *** Bot #$0 options: $bots.querybotopt($word(5 $BOTS[$0]))
  569.         ^timer $rand(5) ^bots.dospyons
  570.         @ BC = 1
  571.     }
  572.     if ([$1] == [RANDNICK])
  573.     {
  574.         @ NEWNICK = randcrap(9)
  575.         //dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) NICK $NEWNICK
  576.         bots.setopt $0 3 $NEWNICK
  577.         ^assign -NEWNICK
  578.         @ BC = 1
  579.     }
  580.     if ([$1] == [CTCP])
  581.     {
  582.         if ([$3]) {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) PRIVMSG $2 :$3-}
  583.         {/echo *** Must specify a target and ctcp-command}
  584.         @ BC = 1
  585.     }
  586.     if ([$1] == [MODE])
  587.     {
  588.         if ([$2])
  589.         {
  590.             if (ischannel($2)) {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) MODE $2 $3-} {/dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) MODE $C $2-}
  591.         } {/echo *** Must specify a mode to change}
  592.         @ BC = 1
  593.     }
  594.     if ([$1] == [QUOTE])
  595.     {
  596.         if ([$2]) {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) $2-} {/echo *** Must specify a line to send to the server}
  597.         @ BC = 1
  598.     }
  599.     if ([$1] == [INVITE])
  600.     {
  601.         if ([$2])
  602.         {
  603.             if ([$3])
  604.             {
  605.                 if (ischannel($3)) {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) INVITE $2 $3} {/dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) INVITE $2 #$3}
  606.             } {//dcc raw $word(0 $BOTS[$0]) $word(1 $BOTS[$0]) INVITE $2 $C}
  607.         } {/echo *** Must specify a nick}
  608.         @ BC = 1
  609.     }
  610.     foreach PP.BOTCMDS AA {$PP.BOTCMDS[$AA] $*}
  611.     if (!(BC)) {/echo *** No such bot command $1}
  612.     ^assign -BC
  613. }
  614.  
  615. # Returns the lowest available bot #
  616. alias bots.getlownum {
  617.     @ LOWEST = 1
  618.     while (BOTS[$LOWEST]) {@ LOWEST = LOWEST + 1}
  619.     @ FUNCTION_RETURN = LOWEST
  620.     ^assign -LOWEST
  621. }
  622.  
  623. # ----------------------------------------------------------------------------
  624. # User /bot and /gb aliases
  625. # ----------------------------------------------------------------------------
  626.  
  627. # MAKE <nick> <server>[:<port>] [<IRCName>]
  628. # LMAKE <nick> <username> <server>[:<port>] [<IRCName>]
  629. # LMASSMAKE <count> <nick-prefix/*> <username> <server>[:<port>] [<IRCName>]
  630. # MASSMAKE <count> <nick-prefix/*> <server>[:<port>] [<IRCName>]
  631. # KILL <botno/*> [<signoff msg>]
  632. # MASSDEOP
  633. alias bot {
  634.     if (rmatch($0 *MAKE KILL LIST MASSDEOP))
  635.     {
  636.         if ([$0] == [MASSDEOP]) {^if (gotops($C)) {/bots.massdeop} {/echo *** You don't have ops on $C}}
  637.         if ([$0] == [LMAKE])
  638.         {
  639.             if ([$3])
  640.             {
  641.                 if (match(*:* $3))
  642.                 {
  643.                     @ BS = left($index(: $3) $3)
  644.                     @ BP = mid(${index(: $3)+1} $rindex($right(1 $3) $3) $3)
  645.                 }
  646.                 {
  647.                     @ BS = [$3]
  648.                     @ BP = 6667
  649.                 }
  650.                 @ BN = bots.getlownum()
  651.                 if ([$4]) {@ BI = [$4-]} {@ BI = tolower($encode($time()))##[ $randcrap($rand(12))]}
  652.                 ^set input_prompt [#${BN}] Creating bot...
  653.                 if (bots.domake($BN $BS $BP $1 $2 $PP.SET.BOTS_DFL_OPT $BI)) {^echo *** Bot #${BN} \($1\) created on $3} {/echo *** Error connecting bot $1 to $3}
  654.                 ^set -input_prompt
  655.                 ^assign -BS
  656.                 ^assign -BP
  657.                 ^assign -BI
  658.                 ^assign -BN
  659.             } {/echo $PP.BHL}
  660.         }
  661.         if ([$0] == [MAKE])
  662.         {
  663.             if ([$2]) {/bot LMAKE $1 $tolower($encode($randcrap($rand(5)))) $2-}
  664.             {/echo $PP.BHM}
  665.         }
  666.         if ([$0] == [KILL])
  667.         {
  668.             if ([$1])
  669.             {
  670.                 if ([$2]) {@ SM = [$2-]} {@ SM = [Leaving]}
  671.                 if ([$1] == [*])
  672.                 {
  673.                     foreach BOTS AA {^bots.dokill $AA $SM}
  674.                     echo *** All bots disconnected
  675.                 }
  676.                 {
  677.                     if (bots.dokill($1 $SM)) {/echo *** Bot #$1 disconnected} {/echo *** No such bot #$1}
  678.                 }
  679.                 ^assign -SM
  680.             } {/echo *** /bot kill <botno/*> [<signoff msg>]}
  681.         }
  682.         if ([$0] == [LIST])
  683.         {
  684.             ^pp.pauseset
  685.             echo *** Bot#   Nick      Server:Port
  686.             foreach BOTS AA {
  687.                 @ BN = word(3 $BOTS[$AA])
  688.                 echo *** $[6]AA $[9]BN $word(1 $BOTS[$AA]):$word(2 $BOTS[$AA])
  689.             }
  690.             ^assign -BN
  691.             ^pp.pauseend
  692.         }
  693.         if ([$0] == [LMASSMAKE])
  694.         {
  695.             if ([$4])
  696.             {
  697.                 @ CN = 0
  698.                   while (CN < [$1])
  699.                 {
  700.                     if ([$3] == [AA]) {@ LU = tolower($encode($randcrap($rand(5))))} {@ LU = [$3]}
  701.                     if ([$2] == [*])
  702.                     {
  703.                         @ NM = rand(4) + 6
  704.                         @ LN = randcrap($NM)
  705.                         ^assign -NM
  706.                     } {@ LN = [$2$bots.getlownum()]}
  707.                     bot LMAKE $LN $LU $4-
  708.                     @ CN = CN + 1
  709.                 }
  710.                 ^assign -LU
  711.                 ^assign -LN
  712.                 ^assign -CN
  713.             } {/echo *** /bot lmassmake <count> <nick-prefix/*> <username> <server>[:<port>] [<IRCName>]}
  714.         }
  715.         if ([$0] == [MASSMAKE]) 
  716.         {
  717.             if ([$3]) {/bot LMASSMAKE $1 $2 AA $3-}
  718.             {/echo *** /bot massmake <count> <nick-prefix/*> <server>[:<port>] [<IRCName>]}
  719.         }
  720.     }
  721.     {
  722.         if ([$1])
  723.         {
  724.             if ([$0] == [*]) {^foreach BOTS ZZ {/bot $ZZ $1-}} {^if (BOTS[$0]) {^bots.action $*} {/echo *** No such bot #$0}}
  725.         } {/echo $PP.BH}
  726.     }
  727.     ^assign -ZZ
  728.     ^bots.makevars
  729. }
  730. # These are to get around a length limit for what can be under an if statement
  731. ^assign PP.BH *** /bot <command> [<options>] -or- /bot <bot#/*> <command> [<options>]
  732. ^assign PP.BHL *** /bot lmake <nick> <username> <server>[:<port>] [<IRCName>]
  733. ^assign PP.BHM *** /bot make <nick> <server>[:<port>] [<IRCName>]
  734. alias bots {/bot $*}
  735.  
  736. # a frontend for /bot to easily make guardbots
  737. alias gb {
  738.     echo *** Press enter for any of these if you don't care.
  739.     ^input "Enter a nickname for your guardbot :" ^if (1) {
  740.         if ([$0]) {@ GBN = [$0]}
  741.         {
  742.             @ GBN = randcrap(9)
  743.             echo *** Using random nickname ${GBN}
  744.         }
  745.         echo *** If you want a port other than 6667, type the port after the server name seperated by a space.
  746.         ^input "Enter a server for your guardbot :" ^if (1) {
  747.             if ([$0]) {@ GBS = [$0]}
  748.             {
  749.                 echo *** Using server: ${S}
  750.                 @ GBS = [$S]
  751.             }
  752.             if ([$1]) {@ GBP = [$1]} {@ GBP = 6667}
  753.             ^input "Enter an IRCName for your guardbot :" ^if (1) {
  754.                 if ([$0]) {@ GBI = [$*]}
  755.                 {
  756.                     echo *** Using default IRCName
  757.                     @ GBI = [[PurePak]]
  758.                 }
  759.                 ^input "Enter a username for your guardbot :" ^if (1) {
  760.                     if ([$0]) {@ GBU = [$0]}
  761.                     {
  762.                         @ GBU = tolower($encode($rand(9999)))
  763.                         echo *** Using random username ${GBU}
  764.                     }
  765.                     echo *** Creating bot...
  766.                     @ GBNUM = bots.getlownum()
  767.                     bot lmake $GBN $GBU ${GBS}:$GBP $GBI
  768.                     bot $GBNUM set OPSGUARD KICKGUARD BANGUARD SPYMSG FOLLOW FOLLOWL
  769.                     bot $GBNUM join $mychannels()
  770.                     echo *** Done... Type /bot kill ${GBNUM} to kill.
  771.                     ^assign -GBNUM
  772.                     ^assign -GBN
  773.                     ^assign -GBU
  774.                     ^assign -GBS
  775.                     ^assign -GBP
  776.                     ^assign -GBI
  777.                 }
  778.             }
  779.         }
  780.     }
  781. }
  782.  
  783. # ----------------------------------------------------------------------------
  784.  
  785. EVAL ^if (!PP.SET.NOSTARTUP) {/echo -- PurePak DCC RAW bots module loaded}
  786.